package com.situ.study.day6;

import org.junit.Test;

public class OOPDemo {
    @Test
    public void test1() {
        int[] array = new int[2];
        //类是抽取所有对象的共同特征
        //类是对象的模板，对象是类的具体实例化，
        //由这个模板构造出一个一个对象来,他们结构一样，但是数据不一样
        int num = 2;
        Student student1 = new Student();
//        student1.id = 1;
//        student1.name = "张三";
//        student1.age = 223;
//        student1.className = "java2212";
        student1.show();
        student1.study();

        Student student2 = new Student();
//        student2.id = 2;
//        student2.name = "李四";
//        student2.age = 21;
//        student2.className = "java221202";
        student2.show();
        student2.study();

        System.out.println("---------------");
        Student[] students = new Student[2];
        students[0] = student1;
        students[1] = student2;
        for (int i = 0; i < students.length; i++) {
            Student student = students[i];
            //System.out.println(student.print());
            //com.situ.study.day6.Student@5b80350b
            System.out.println(student.toString());
            System.out.println(student);
        }
    }

    @Test
    public void test2() {
        //通过无参构造方法new对象
        Student student1 = new Student();
        student1.setId(1);
        student1.setName("王五");
        student1.setAge(23);
        student1.setClassName("Java2212");
        System.out.println(student1);

        //通过有参构造方法构造对象
        Student student2 = new Student(2, "李四", 23, "Java2212");
        System.out.println(student2);

    }
}
